package echecs.gen;

import echecs.ia.AEvaluation;
import echecs.launch.ChessInterface;
import javax.swing.JApplet;

public abstract class AGenerateurB extends AEvaluation implements ChessInterface {

    public AGenerateurB(JApplet ref) {
        super(ref);
    }

    public void addMove(int start, int end) {
        movelist[movecounter] = start * 100 + end;
        movecounter++;
    }

    public boolean isInBoard(int end) {
        return !((board[end] == 99) || (board[end] % 100 / 10 == color));
    }

    public void changePawnIfLastRange(int end) {
        if ((board[end] % 10 == 1) && ((end < 29) || (end > 90))) {
            //change pawn
            board[end] += 4;
        }
    }

    public int[] simuleMove(int start, int end) {
        int[] ret = new int[2];
        ret[0] = board[start];
        ret[1] = board[end];
        board[end] = board[start];
        board[start] = 0;
        return ret;
    }

    public void undoSimuleMove(int start, int[] ret, int end) {
        board[start] = ret[0];
        board[end] = ret[1];
    }

    public boolean ishHumanMoveValid(int move) {
        for (int i = 0; i < movecounter; i++) {
            if (movelist[i] == move) {
                return true;
            }
        }
        return false;
    }
}
